<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/8/5
  Time: 11:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%String path = request.getContextPath()+"/";%>

<html>
<head>
    <base href="<%=path%>">
    <title>编辑用户信息</title>
    <link rel="stylesheet" href="js/bootstrap/css/bootstrap.css">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="js/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="js/jquery.validate.js"></script>
</head>
<body style="overflow-x: hidden">
<form class="form-horizontal" id="form1">
    <input type="hidden" name="parentId" id="parentId" value="0">
    <input type="hidden" name="id" value="${menu.id}" id="menuId">
    <div class="form-group">
        <label  class="col-sm-2 control-label">上级菜单</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="parentName" value="主目录" name="parentName" onclick="$.operator.addOrEdit('/menu/toZTree/','上级菜单')"   >
        </div>
    </div>
    <div class="form-group">
        <label  class="col-sm-2 control-label">菜单类型</label>
        <div class="col-sm-10">
          <input type="radio" name="menuType" value="0" onclick="changeOpen(this)">目录
            <input type="radio" name="menuType" value="1" onclick="changeOpen(this)" checked>菜单
            <input type="radio" name="menuType" value="2" onclick="changeOpen(this)">按钮
        </div>
    </div>
    <div class="form-group">
        <label  class="col-sm-2 control-label">菜单名称</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="menuName" value="${menu.menuName}" >
        </div>
    </div>

    <div class="form-group" id="urlDiv">
            <label  class="col-sm-2 control-label">请求地址</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="url" value="${menu.url}" >
        </div>
    </div>

    <div class="form-group" id="openDiv">
        <label  class="col-sm-2 control-label">打开方式</label>
        <div class="col-sm-10">
            <select class="form-control" name="openType">
                <option value="0" <c:if test="${menu.openType==0}">selected</c:if> >页签</option>
                <option value="1"  <c:if test="${menu.openType==1}">selected</c:if> >新窗口</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label  class="col-sm-2 control-label">权限标识</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="permission" value="${menu.permission}" >
        </div>
    </div>

    <div class="form-group" id="showDiv">
        <label  class="col-sm-2 control-label">显示排序</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="showOrder" value="${menu.showOrder}" >
        </div>
    </div>
    <div class="form-group" id="iconDiv">
        <label  class="col-sm-2 control-label">图标</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="icon" value="${menu.icon}" >
        </div>
    </div>
    <div class="form-group" id="listDiv">
        <label  class="col-sm-2 control-label">菜单状态</label>
        <div class="col-sm-4">
            <label class="radio-inline">
                <input type="radio" name="status"  value="0" <c:if test="${menu.status==0}">checked</c:if>> 显示
                <input type="radio" name="stauts"  value="1" <c:if test="${menu.status==1}">checked</c:if> style="margin-left: 2px"> <span style="margin-left:20px">隐藏</span>
            </label>
        </div>
        <div id="refreshDiv">
            <label  class="col-sm-2 control-label">是否刷新</label>
            <div class="col-sm-4">
                <label class="radio-inline">
                    <input type="radio" name="isRefresh"  value="1" <c:if test="${menu.isRefresh==1}">checked</c:if>> 是
                    <input type="radio" name="isRefresh"  value="0" <c:if test="${menu.isRefresh==0}">checked</c:if> style="margin-left: 2px"> <span style="margin-left:20px">否</span>
                </label>
            </div>
        </div>

    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-success" onclick="save();"><span class="glyphicon glyphicon-floppy-disk"></span> 保存</button>
            <button type="reset" class="btn btn-danger"><span class="glyphicon glyphicon-repeat"></span> 重置</button>
        </div>
    </div>
</form>
</body>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script type="text/javascript" src="js/bootstrap/rbac.js"></script>
<script>

    function save(){
        if(!$("#form1").valid()){
            return;
        }
     $.operator.save('menu/save',$("#form1").serialize());
    }

    function item(menuId,menuName){
           $('#parentName').val(menuName);
           $('#parentId').val(menuId);
    }
    function close(){
        layer.close(index);
    }
     function  showALL(){
        $("#urlDiv").show();
        $("#openDiv").show();
        $("#showDiv").show();
        $("#refreshDiv").show();
        $("#iconDiv").show();
        $("#listDiv").show();
    }
    function changeOpen(obj){

       if(obj.value==0) {
           showALL();
          $("#urlDiv").hide();
           $("#openDiv").hide();
           $("#showDiv").hide();
           $("#refreshDiv").hide();
       }

        if(obj.value==2) {
            showALL();
            $("#urlDiv").hide();
            $("#openDiv").hide();
            $("#iconDiv").hide();
            $("#listDiv").hide();
        }
        if(obj.value==1) {
            showALL();
        }
    }

    $("#form1").validate({
        rules:{
            menuName:'required',
        },
        messages:{
            menuName: '名字不能为空'
        }
    })
</script>
</html>
